//
//  MemoryStream.h
//  Protocol
//
//  Created by  user on 11-1-9.
//  Copyright 2011 GuangZhouXuanWu. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface CMemoryStream : NSObject
{
    NSMutableData *_data;
	NSUInteger _position;
}

@property(nonatomic,assign)NSUInteger position;
@property(nonatomic,assign)NSUInteger length;
@property(nonatomic,readonly)NSMutableData *data;

- (void)appendBytes:(const void *)bytes length:(NSUInteger)length;

- (void)appendData:(NSData *)other;

- (void)increaseLengthBy:(NSUInteger)extraLength;

- (void)replaceBytesInRange:(NSRange)range withBytes:(const void *)bytes;

- (void)resetBytesInRange:(NSRange)range;

- (void)replaceBytesInRange:(NSRange)range withBytes:(const void *)replacementBytes length:(NSUInteger)replacementLength;

- (NSData *)subdataWithRange:(NSRange)range;

- (void)getBytes:(void *)buffer length:(NSUInteger)length;

- (void)getBytes:(void *)buffer range:(NSRange)range;

- (BOOL)isEqualToData:(CMemoryStream *)other;

- (NSString *)description;

-(BOOL)isEndPosition;

@end
